' --------------------------------------------------------------
' ENGLISH: Bit sequences for the "Rele Switcher"
' www.theremino.com/en/hardware/outputs/actuators#releswitcherv2
' --------------------------------------------------------------
' ITALIANO: Sequenze di bit per il "Rel? Switcher"
' www.theremino.com/hardware/outputs/actuators#releswitcherv2
' --------------------------------------------------------------
Option Speed 9
Key 1 Goto 1
Key 2 Goto 2
Key 3 Goto 3
Stop

Label 1
	s1 = "0000000000000000"
	Gosub SendSequence
Stop

Label 2
	s1 = "1010010001000100"
	Gosub SendSequence
Stop

Label 3
	s1 = "1111111111111111"
	Gosub SendSequence
Stop

' --------------------------------------------------------------
'  Send Sequence
' --------------------------------------------------------------
'  Slot 1 is Store 
'  Slot 2 is Data
'  Slot 3 is Clock
' --------------------------------------------------------------
Label SendSequence
	v1 = 1
	Slot 1 = 0				' Slot 1(Store) = 0
	Label Loop
		If Mid(s1, v1, 1) = "0"
			Slot 2 = 0		' Slot 2(Data)  = 0
		Else
			Slot 2 = 1000	' Slot 2(Data)  = 1000
		EndIf
		Slot 3 = 0			' Slot 3(Clock) = 0
		Wait Seconds 0.004
		Slot 3 = 1000		' Slot 3(Clock) = 1000
		Wait Seconds 0.004
		v1 = v1 + 1
		If v1 <= Len(s1)
			Goto Loop
		EndIf
		Slot 1 = 1000		' Slot 1(Store) = 1000
		Wait Seconds 0.004
		Slot 2 = 0			' Slot 2(Data)  = 0
		Slot 3 = 0			' Slot 3(Clock) = 0
		'Slot 1 = 0			' Slot 1(Store) = 0 (only for some hardware)	
	Return
	
